package com.aaa.spring.controller;


import com.aaa.spring.pojo.GoodsInfo;
import com.aaa.spring.pojo.Result;
import com.aaa.spring.service.GoodsInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//标识这是个控制器 控制跳转的
@Controller   //相当于 将 @Controller + @ResponseBody
@RequestMapping("/goods")
public class GoodsController {
    //声明日志变量
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private GoodsInfoService goodsInfoService;

    /**
     * 提交
     * @return
     */
    @ResponseBody
    @PostMapping("submit")
    public Result submit(@RequestBody GoodsInfo goodsInfo){
        Result result = goodsInfoService.add(goodsInfo);
        return result;
    }

    /**
     * 类型列表
     * @return
     */
    @ResponseBody
    @GetMapping("getTypeList")
    public Result getTypeList(){
        Result result = goodsInfoService.getTypeList();
        return result;
    }
    /**
     * 商品列表
     * @return
     */
    @ResponseBody
    @GetMapping("getGoodsInfoList")
    public Result getGoodsInfoList(){
        Result result = goodsInfoService.getGoodsInfoList();
        return result;
    }





}
